#include "head.h"

// 初始化线程池
int init_pool(pool_t *pool, int num){
    // 初始化数组:
    pool->pthread_id = (pthread_t *)calloc(num, sizeof(pthread_t));
    // 创建对应的子线程
    for(int i = 0; i < num; i++){
        // 创建子线程
        pthread_create(&pool->pthread_id[i], NULL, pthread_fun, pool);
    }

    pool->num = num;

    //初始化队列和锁
    memset(&pool->queue, 0, sizeof(queue_t));
    // 初始化锁和条件遍历
    pthread_mutex_init(&pool->pthread_lock, NULL);
    pthread_cond_init(&pool->cond, NULL);
    return 0;
}
